<template>
	<view>
		<uni-nav-bar :fixed="true" left-icon="back" title="意见反馈" @clickLeft="leftBack" background-color="#318cff" color="#fff"></uni-nav-bar>
		<view class="dfj-bg-white dfj-mg-lr-30 dfj-bd-radius-10 dfj-pd-lr-20">
			<view class="dfj-flex dfj-flex-ai-c dfj-t-333 dfj-bd-b-e5e">
				<view class="dfj-flex-1">姓名:</view>
				<view class="dfj-flex-4"><input type="text" class="dfj-pd-tb-30" v-model="form.userName" placeholder="请输入您的姓名"></view>
			</view>
			<view class="dfj-flex dfj-flex-ai-c dfj-t-333 dfj-bd-b-e5e">
				<view class="dfj-flex-1">电话:</view>
				<view class="dfj-flex-4"><input type="text" class="dfj-pd-tb-30" v-model="form.phone" placeholder="请输入您的电话"></view>
			</view>
			<view class="dfj-flex dfj-flex-ai-c dfj-t-333 dfj-bd-b-e5e">
				<view class="dfj-flex-1">邮箱:</view>
				<view class="dfj-flex-4"><input type="text" class="dfj-pd-tb-30" v-model="form.email" placeholder="请输入您的邮箱"></view>
			</view>
			<view class="dfj-flex dfj-flex-ai-c dfj-t-333 dfj-bd-b-e5e">
				<view class="dfj-flex-1">地址:</view>
				<view class="dfj-flex-4"><input type="text" class="dfj-pd-tb-30" v-model="form.address" placeholder="请输入您的地址"></view>
			</view>
		</view>
		
		<view class="dfj-bg-white dfj-pd-30 dfj-mg-30">
			<textarea value="" placeholder="请输入反馈内容" v-model="form.msg"/>
		</view>
		
		<view class="dfj-pd-30"><button type="primary" @click="optFeedback">提交反馈</button></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					userName: '',
					phone: '',
					email: '',
					address: '',
					msg: ''
				}
			}
		},
		methods: {
			leftBack() {
				uni.navigateBack();
			},
			optFeedback(){
				if(this.form.userName == ''){
					uni.showToast({
						title: '请输入姓名',
						icon: 'none'
					})
					setTimeout(()=>{
						uni.hideToast();
					},1000)
				}
				if(this.form.phone == ''){
					uni.showToast({
						title: '请输入电话',
						icon: 'none'
					})
					setTimeout(()=>{
						uni.hideToast();
					},1000)
				}
				if(this.form.msg == ''){
					uni.showToast({
						title: '请输入反馈内容',
						icon: 'none'
					})
					setTimeout(()=>{
						uni.hideToast();
					},1000)
				}
				this.$http({
					url: '/userOpt/optFeedback',
					data: this.form
				}).then(res=> {
					console.log(res)
					if(res.flag){
						uni.showToast({
							title: '提交成功'
						})
						setTimeout(()=>{
							uni.hideToast()
							uni.navigateBack()
						})
					}
				})
			}
		}
	}
</script>

<style>
</style>
